package ThreadDemo;

import java.util.Scanner;

public class ThreadDemo16 {


    public static void main(String[] args) {
        Thread t1 = new Thread() {
            @Override
            public void run() {
                while(true){
                    System.out.println("t1获取到了线程");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        Scanner sc=new Scanner(System.in);
        Thread t2 = new Thread() {
            @Override
            public void run() {
                while(true) {
                    System.out.println("请输入一个整数：");
                    int a = sc.nextInt();
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        };
        t1.start();
        t2.start();
    }
}
